package com.aspose.cells;

class ziw implements zagc {
   private zif c;
   private zas d;
   private zalv e;
   private com.aspose.cells.b.a.b.zg f;
   private zxp g;
   private Color h;
   private int i;
   private int j;
   private int k;
   private int l;
   com.aspose.cells.b.a.b.zp a = com.aspose.cells.b.a.b.zp.a();
   com.aspose.cells.b.a.b.zp b = com.aspose.cells.b.a.b.zp.a();
   private boolean m = true;
   private boolean n = true;
   private boolean o = true;
   private Object p = null;
   private int q;
   private boolean r = true;
   private int s;
   private int t;
   private int u;
   private boolean v = false;
   private boolean w = false;

   ziw(zif var1, Object var2, int var3) {
      this.c = var1;
      this.k = 0;
      this.l = 0;
      this.i = 0;
      this.j = 0;
      this.d = new zas(var1);
      this.e = new zalv(var1);
      this.h = Color.getBlack();
      this.a = com.aspose.cells.b.a.b.zp.a();
      this.b = com.aspose.cells.b.a.b.zp.a();
      this.p = var2;
      this.q = var3;
      this.g = new zxp();
   }

   zif a() {
      return this.c;
   }

   Object b() {
      return this.p;
   }

   public void a(boolean var1) {
      this.r = var1;
   }

   public boolean c() {
      return this.v;
   }

   public void b(boolean var1) {
      this.v = var1;
   }

   zas d() {
      return this.d;
   }

   public zafn e() {
      return this.d;
   }

   zalv f() {
      return this.e;
   }

   public zahf g() {
      return this.e;
   }

   public com.aspose.cells.b.a.b.zg h() {
      if (this.f == null) {
         if (this.q == 0) {
            this.f = zbuk.a("Arial", 10.0F, 0);
            this.a(Color.getBlack());
         } else {
            this.f = zbuk.a(this.c.Z());
            this.a(this.c.aa());
         }
      } else if (this.k().d() || this.k().c()) {
         com.aspose.cells.b.a.b.zg var1 = new com.aspose.cells.b.a.b.zg(this.f.b(), 0.7F * this.f.h(), this.f.k());
         return var1;
      }

      return this.f;
   }

   public void a(com.aspose.cells.b.a.b.zg var1) {
      this.f = var1;
   }

   com.aspose.cells.b.a.b.zg i() {
      if (this.f == null) {
         if (this.q == 0) {
            this.f = zbuk.a("Arial", 10.0F, 0);
            this.a(Color.getBlack());
         } else {
            this.f = zbuk.a(this.c.Z());
            this.a(this.c.aa());
         }
      }

      return this.f;
   }

   void b(com.aspose.cells.b.a.b.zg var1) {
      this.f = var1;
   }

   public Color j() {
      return this.h;
   }

   public void a(Color var1) {
      this.h = var1;
   }

   public zagt k() {
      return this.g;
   }

   public int l() {
      switch(this.q) {
      case 1:
      case 10:
         if (!this.s() && this.i + this.n() > 4000) {
            return 4000 - this.n();
         }

         return this.i;
      default:
         return this.i;
      }
   }

   public void a(int var1) {
      this.i = var1;
      this.o = false;
   }

   public int m() {
      switch(this.q) {
      case 1:
      case 10:
         if (!this.s() && this.j + this.o() > 4000) {
            return 4000 - this.o();
         }

         return this.j;
      default:
         return this.j;
      }
   }

   public void b(int var1) {
      this.j = var1;
      this.o = false;
   }

   public int n() {
      switch(this.q) {
      case 1:
      case 10:
         return this.k < 0 ? 0 : this.k;
      default:
         return this.k;
      }
   }

   public void c(int var1) {
      this.k = var1;
      this.m = false;
   }

   public int o() {
      switch(this.q) {
      case 1:
      case 10:
         return this.l < 0 ? 0 : this.l;
      default:
         return this.l;
      }
   }

   public void d(int var1) {
      this.l = var1;
      this.n = false;
   }

   public com.aspose.cells.b.a.b.zp p() {
      return new com.aspose.cells.b.a.b.zp(this.k, this.l, this.i, this.j);
   }

   public boolean q() {
      return this.m;
   }

   public void c(boolean var1) {
      this.m = var1;
   }

   public boolean r() {
      return this.n;
   }

   public void d(boolean var1) {
      this.n = var1;
   }

   public boolean s() {
      return this.o;
   }

   public void e(boolean var1) {
      this.o = var1;
   }

   com.aspose.cells.b.a.b.zs t() throws Exception {
      int var1 = zbuk.c((double)((float)this.l() * (float)this.F() / (float)this.H()));
      int var2 = zbuk.c((double)((float)this.m() * (float)this.G() / (float)this.H()));
      return new com.aspose.cells.b.a.b.zs(var1, var2);
   }

   int u() throws Exception {
      return zbuk.c((double)((float)this.l() * (float)this.F() / (float)this.H()));
   }

   int v() throws Exception {
      return zbuk.c((double)((float)this.m() * (float)this.G() / (float)this.H()));
   }

   int w() throws Exception {
      return zbuk.c((double)((float)this.n() * (float)this.F() / (float)this.H()));
   }

   int x() throws Exception {
      return zbuk.c((double)((float)this.o() * (float)this.G() / (float)this.H()));
   }

   int y() {
      int var1 = 14;
      int var2 = zhz.c;
      if (this.q == 12) {
         if (this.p instanceof zbcp) {
            var1 = ((zbcp)this.p).ag();
         } else {
            var1 = ((zjd)this.p).g().a().ag();
         }
      }

      return var1;
   }

   void z() throws Exception {
      this.a.a(this.b.c());
      this.a.b(this.b.d());
      this.a.c(this.b.e());
      this.a.d(this.b.f());
      int var1 = this.y();
      int var2 = zhz.c;
      if (this.q != 12 || var1 != 44 && var1 != 35) {
         if (!this.o && this.q == 10) {
            com.aspose.cells.b.a.b.zs var3 = this.t();
            this.a.c(var3.b());
            this.a.d(var3.c());
         }

         zbo var4;
         int var5;
         int var6;
         int var7;
         if (!this.m) {
            if (this.q == 12 && !this.c() || this.q == 16 && !this.c()) {
               var6 = this.a.c();
               if (var1 != 6 && var1 != 7 && var1 != 8) {
                  var6 += this.w();
               } else {
                  var7 = this.k;
                  this.k = this.l;
                  var6 -= this.w();
                  this.k = var7;
               }

               this.a.a(var6 >= var2 ? var6 : var2);
               if (this.a.i() + var2 > this.c.a()) {
                  this.a.a(this.c.a() - var2 - this.a.e());
               }
            } else if (this.q == 8 && !this.c() || this.q == 9 && !this.c() || this.q == 13 && !this.c()) {
               var6 = this.a.c();
               if (this.b() instanceof zbo && this.q == 9) {
                  var4 = (zbo)this.b();
                  if (var4.a() != 1 && var4.a() != 2) {
                     if (var4.a() != 0 && var4.a() != 3) {
                        var6 += this.w();
                     } else {
                        var5 = this.k;
                        this.k = this.l;
                        var6 += this.w();
                        this.k = var5;
                     }
                  } else if (var4.n) {
                     var6 += this.w();
                  } else {
                     var6 -= this.w();
                  }
               } else {
                  var6 += this.w();
               }

               this.a.a(var6 >= var2 ? var6 : var2);
               if (this.a.i() + var2 > this.c.a()) {
                  this.a.a(this.c.a() - var2 - this.a.e());
               }
            } else if (this.q != 1) {
               if (this.q == 10) {
                  this.a.a(this.w());
                  this.a.a(this.a.c() + var2);
               } else {
                  this.a.a(this.w());
               }
            }
         }

         if (!this.n) {
            if ((this.q != 12 || this.c()) && (this.q != 16 || this.c())) {
               if (this.q == 8 && !this.c() || this.q == 9 && !this.c() || this.q == 13 && !this.c()) {
                  var6 = this.a.d();
                  if (this.b() instanceof zbo && this.q == 9) {
                     var4 = (zbo)this.b();
                     if (var4.a() != 1 && var4.a() != 2) {
                        if (var4.a() != 0 && var4.a() != 3) {
                           var6 += this.x();
                        } else {
                           var5 = this.l;
                           this.l = this.k;
                           if (var4.n) {
                              var6 -= this.x();
                           } else {
                              var6 += this.x();
                           }

                           this.l = var5;
                        }
                     } else {
                        var6 -= this.x();
                     }
                  } else {
                     var6 += this.x();
                  }

                  this.a.b(var6 >= var2 ? var6 : var2);
                  if (this.a.j() + var2 > this.c.b()) {
                     this.a.b(this.c.b() - var2 - this.a.f());
                  }
               } else if (this.q != 1) {
                  if (this.q == 10) {
                     this.a.b(this.x());
                     this.a.b(this.a.d() + var2);
                  } else {
                     this.a.b(this.x());
                  }
               }
            } else {
               var6 = this.a.d();
               if (var1 != 6 && var1 != 7 && var1 != 8) {
                  var6 += this.x();
               } else {
                  var7 = this.l;
                  this.l = this.k;
                  var6 -= this.x();
                  this.l = var7;
               }

               this.a.b(var6 >= var2 ? var6 : var2);
               if (this.a.j() + var2 > this.c.b()) {
                  this.a.b(this.c.b() - var2 - this.a.f());
               }
            }
         }

      }
   }

   void e(int var1) {
      this.s = var1;
   }

   void f(int var1) {
      this.t = var1;
   }

   private int F() throws Exception {
      int var1 = zhz.c;
      switch(this.q) {
      case 1:
      case 8:
      case 10:
         return this.c.a() - 2 * var1;
      default:
         return this.c() ? this.c.a() - 2 * var1 : this.s;
      }
   }

   private int G() throws Exception {
      int var1 = zhz.c;
      switch(this.q) {
      case 1:
      case 8:
      case 10:
         return this.c.b() - 2 * var1;
      default:
         return this.c() ? this.c.b() - 2 * var1 : this.t;
      }
   }

   private int H() {
      switch(this.q) {
      case 1:
      case 8:
      case 10:
         return 4000;
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      case 11:
      case 14:
      case 15:
      default:
         return this.u;
      case 9:
      case 12:
      case 13:
      case 16:
         return this.c() ? 4000 : 1000;
      }
   }

   com.aspose.cells.b.a.b.zp A() throws Exception {
      this.z();
      com.aspose.cells.b.a.b.zp var1 = new com.aspose.cells.b.a.b.zp(this.a.c(), this.a.d(), this.a.e(), this.a.f());
      int var2 = zhz.c;
      if (var1.c() > var2) {
         var1.a(var1.c() - var2);
      }

      if (var1.d() > var2) {
         var1.b(var1.d() - var2);
      }

      short var3 = 4000;
      int var4 = this.c.b() - 2 * var2;
      int var5 = this.c.a() - 2 * var2;
      int var6 = 14;
      if (this.q == 12) {
         if (this.p instanceof zbcp) {
            var6 = ((zbcp)this.p).ag();
         } else {
            var6 = ((zjd)this.p).g().a().ag();
         }
      }

      if (this.q == 12) {
         if (var6 == 6) {
            var1.a(zbuk.c((double)var3 * (double)var1.d() / (double)var4));
         } else {
            var1.a(zbuk.c((double)var3 * (double)var1.c() / (double)var5));
         }
      } else {
         var1.a(zbuk.c((double)var3 * (double)var1.c() / (double)var5));
      }

      if (this.q == 12) {
         if (var6 == 6) {
            var1.b(zbuk.c((double)var3 * (double)var1.c() / (double)var5));
         } else {
            var1.b(zbuk.c((double)var3 * (double)var1.d() / (double)var4));
         }
      } else {
         var1.b(zbuk.c((double)var3 * (double)var1.d() / (double)var4));
      }

      var1.c(zbuk.c((double)var3 * (double)var1.e() / (double)var5));
      var1.d(zbuk.c((double)var3 * (double)var1.f() / (double)var4));
      return var1;
   }

   com.aspose.cells.b.a.b.zp B() throws Exception {
      com.aspose.cells.b.a.b.zp var1 = new com.aspose.cells.b.a.b.zp(this.b.c(), this.b.d(), this.b.e(), this.b.f());
      int var2 = zhz.c;
      if (var1.c() > var2) {
         var1.a(var1.c() - var2);
      }

      if (var1.d() > var2) {
         var1.b(var1.d() - var2);
      }

      var1.a(zbuk.c((double)this.H() * (double)var1.c() / (double)this.F()));
      var1.b(zbuk.c((double)this.H() * (double)var1.d() / (double)this.G()));
      var1.c(zbuk.c((double)this.H() * (double)var1.e() / (double)this.F()));
      var1.d(zbuk.c((double)this.H() * (double)var1.f() / (double)this.G()));
      return var1;
   }

   float C() {
      return (float)zbuk.a((double)this.a().ap().a().a(this.i()));
   }

   boolean D() throws Exception {
      this.z();
      return this.a.e() <= 0 || this.a.f() <= 0;
   }

   protected void finalize() throws Exception {
      this.f(false);
   }

   public void E() {
      this.f(true);
      com.aspose.cells.b.a.zg.a(this);
   }

   protected void f(boolean var1) {
      if (!this.w) {
         if (var1) {
            if (this.f != null) {
               this.f.n();
            }

            if (this.d != null) {
               this.d.i();
            }
         }

         this.w = true;
      }

   }
}
